<?php
//Include the 2 important files
require_once("functions.php");
require_once("Connections/cnn.php");

//Start the session and take the values
session_start();
$sID = $_SESSION['memberID'];

//Declare SQL Query
$sql = "UPDATE Members
SET Firstname 	= '{$_REQUEST['firstname']}', 
	Lastname 	= '{$_REQUEST['lastname']}', 
	Phone 		= '{$_REQUEST['phone']}', 
	DOB 		= '{$_REQUEST['DOB']}', 
	Gender 		= '{$_REQUEST['gender']}', 
	IDcard 		= '{$_REQUEST['idcard']}', 
	Address 	= '{$_REQUEST['address']}', 
	City 		= '{$_REQUEST['city']}', 
	Job 		='{$_REQUEST['job']}'
WHERE ID = {$sID}";

//Debug sql query
//echo "$sql";

//Create the var time to show when use update info
$timezone = +7;
$time = gmdate("Y-m-d H:i:s", time() + 3600*($timezone+date("I")));

//Exec sql Query
$updateQuery = @mysql_query("$sql");

//Check SQL Query.
//This is the update query, so the result will return true (1) or false (0)
if($updateQuery) //if($updateQuery) means if($updateQuery = true) or if($updateQuery = 1)
{
	//Declare var Msg
	$errorMsg = "Update successfull"; 
	//Redirect is function was define in functions.php
	//Assign the var Msg and var Time into URL and back to editaccount.php
	//errorMsg and fixtime are two var that we will use $_REQUEST['Var Name'] to get the value on next page
	Redirect('editaccount.php?errorMsg='."$errorMsg".'&&fixtime='."$time".'');	
}
else
{
	//Same of above
	$errorMsg = "Update False"; 
	Redirect('editaccount.php?errorMsg='."$errorMsg".'&&fixtime='."$time".'');
}

?>